<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="../jquery/jquery-3.6.0.min.js"></script>
    <title>Document</title>
    <style>
        input{
            width: 150px;
            height: 150px;
        }
        button{
            width: 90px;
            height: 50px;
        }
    </style>
</head>
<body>
    <input type="checkbox" name="qwe">
    <input type="checkbox" name="qwe">
    <input type="checkbox" name="qwe">
    <input type="checkbox" name="qwe">
    <input type="checkbox" name="qwe">
    <input type="checkbox" name="qwe"><br>
    <input type="checkbox" name="qwe">
    <input type="checkbox" name="qwe">
    <input type="checkbox" name="qwe">
    <input type="checkbox" name="qwe">
    <input type="checkbox" name="qwe">
    <input type="checkbox" name="qwe"><br>
    <input type="checkbox" name="qwe">
    <input type="checkbox" name="qwe">
    <input type="checkbox" name="qwe">
    <input type="checkbox" name="qwe">
    <input type="checkbox" name="qwe">
    <input type="checkbox" name="qwe"><br>
    <input type="checkbox" name="qwe">
    <input type="checkbox" name="qwe">
    <input type="checkbox" name="qwe">
    <input type="checkbox" name="qwe">
    <input type="checkbox" name="qwe">
    <input type="checkbox" name="qwe"><br>
    <input type="checkbox" name="qwe">
    <input type="checkbox" name="qwe">
    <input type="checkbox" name="qwe">
    <input type="checkbox" name="qwe">
    <input type="checkbox" name="qwe">
    <input type="checkbox" name="qwe"><br>
    <button id="q1">全选</button>
    <button id="q2">反选</button>
    <button id="q3">不选</button>
</body>
<script> 
    var a = $('[name = "qwe"]')
    $('#q1').click(function(){
        for(i=0;i<=a.length-1;i++){
          if(a[i].checked  == false){
            a[i].checked = true
            }
        }
    })

    $('#q2').click(function(){
        for(i=0;i<=a.length-1;i++){
          if(a[i].checked  == true){
            a[i].checked = false
        }else if(a[i].checked  == false){
            a[i].checked = true
            }
        }
    })


    $('#q3').click(function(){
        for(i=0;i<=a.length-1;i++){
          if(a[i].checked  == true){
            a[i].checked = false
            }
        }
    })


</script>
</html>